package com.rimi.lzhg.service.impl;

import com.rimi.lzhg.dao.TypeMapper;
import com.rimi.lzhg.entry.Type;
import com.rimi.lzhg.service.TypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TypeServiceImpl implements TypeService {

    @Autowired
    private TypeMapper typeMapper;

    @Override
    public List<Type> getTypeList() {
        return typeMapper.selectByExample(null);
    }

    @Override
    public Type getTypeById(Integer id) {
        return typeMapper.selectByPrimaryKey(id);
    }

    @Override
    public boolean addType(Type type) {
        if(typeMapper.insert(type)>0){
            return true;
        }
        return false;
    }

    @Override
    public boolean deleteType(int id) {
        if(typeMapper.deleteByPrimaryKey(id)>0){
            return true;
        }
        return false;
    }

    @Override
    public boolean updateType(Type type) {
        if(typeMapper.updateByPrimaryKey(type)>0){
            return true;
        }
        return false;
    }
}
